{extend name="main/index" /}
{block name="main"}
<!-- Start right content -->
<div class="content-page">
    <!-- ============================================================== -->
    <!-- Start Content here -->
    <!-- ============================================================== -->
    <div class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h4><strong>用户管理 </strong>
                            <small>></small>
                            用户列表
                        </h4>
                        <div class="additional-btn">
                            <a href="#" class="hidden reload"><i class="icon-ccw-1">添加</i></a>
                            <a href="#" class="widget-toggle"><i class="icon-down-open-2"></i></a>
                            <a href="#" class="widget-close"><i class="icon-cancel-3"></i></a>
                        </div>
                    </div>
                    <div class="widget-content">
                        <div class="data-table-toolbar">
                            <div class="row">
                                <div class="col-md-4">
                                    <form role="form">
                                        <input type="text" class="form-control" placeholder="Search...">
                                    </form>
                                </div>
                            </div>
                        </div>

                        <div class="table-responsive">
                            <table data-sortable class="table table-hover table-striped">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>用户名</th>
                                    <th>电话</th>
                                    <!-- <th>所属角色</th> -->
                                    <th class="col-md-4">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {volist name="list" id="v"}
                                <tr>
                                    <td id="uid">{$v.id}</td>
                                    <td>{$v.name}</td>
                                    <td>{$v.tel}</td>
                                    
                                    <td>
                                        <!-- <a class="btn btn-danger del-btn"
                                           href="{:url('admin/user/delete', ['id'=>$v['id']])}"><i
                                                class="fa fa-trash-o"></i> 删除</a> -->
                                        <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#myModal" data-id="{$v.id}" id="del">
                                          <i class="fa fa-trash-o"></i> 删除
                                        </button>
                                        <a class="btn btn-primary show-btn"
                                           href="{:url('admin/user/edit', ['id'=>$v['id']])}"><i
                                                class="fa fa-refresh"></i> 修改</a>
                                        <a class="btn btn-success"
                                           href=""><i
                                                class="fa fa-plus-circle"></i> 分配角色</a>
                                        
                                    </td>

                                </tr>
                                {/volist}

                                </tbody>
                            </table>

                            
                        </div>

                        <div class="data-table-toolbar">
                            <ul class="pagination">
                                <li class="disabled"><a href="#">&laquo;</a></li>
                                <li class="active"><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a href="#">&raquo;</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <!-- Footer Start -->
        <footer>
            倚楼听风雨 &copy; 2018
            <div class="footer-links pull-right">
                <a href="#">关于</a>
                <a href="#">支持</a>
                <a href="#">服务</a>
                <a href="#">反馈</a>
                <a href="#">帮助</a>
                <a href="#">联系我们</a>
            </div>
        </footer>
        <!-- Footer End -->
    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>
<!-- End right content -->




<!-- 模态框 - 删除 -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">删除用户</h4>
      </div>
      <div class="modal-body">
        <h2>您确定要删除吗?</h2>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" id="dodel">确定</button>
      </div>
    </div>
  </div>
</div>





{/block}


{block name='myjs'}
    <script>
        // 设置弹框参数
        toastr.options = {
            closeButton: true,//是否显示关闭按钮
            progressBar: true,//实现显示计时条
            timeOut: "3000",//自动关闭时间
            positionClass: "toast-bottom-left"//提示位置
            // toast-top-full-width 顶端，宽度铺满整个屏幕
            // toast-top-right  顶端右边
        };


            $('#dodel').click(function(){
                var id = $('#del').attr('data-id');
                // console.log(id);
                $.ajax({
                    url: '/admin/User/delete',
                    type: 'POST',
                    data: 'id='+id,
                    success: function (data) {
                        console.log(data);
                        if (data.status) {
                            // toastr.success('恭喜!删除记录成功!');
                            alert('删除成功！');
                            window.location.reload();//刷新当前页面.
                            return false;
                        }
                        else{
                            alert('删除失败！');
                            return false;
                        }
                    },
                    error:function(){
                        alert('ajax失败');
                    }
                });
                // 这句是为了让模态框点击关闭
                $('#dodel').attr('data-dismiss','modal');
            })
    </script>

{/block}



